package CMP_CLASS;

public class Example {
    public void privateMethod(Object object1, Object object2) {
        if (object1.getClass().getName().equals("anotherClass")) {// wrong
            // do work based on the assumption we're dealing with
            // the right object
        }
        if (object1.getClass() == object2.getClass()) { // correct
            // do work based on the fact that the objects are the
            // of the same class
        }
    }
}
